Geodatabase Schema Overview
===========================

The contents of an :term:`NG911 geodatabase` must conform to the specifications set out in the Standard.

Feature Datasets
----------------

The geodatabase should contain at its top level two feature datasets: the :term:`required feature dataset` :ng911ds:`required` and the :term:`optional feature dataset` :ng911ds:`optional`. Both feature datasets should use a coordinate reference system prescribed by the Standard.

Feature Classes
---------------

A compliant geodatabase must contain eight feature classes in the :ng911ds:`required` feature dataset. These include the point feature class :ng911fc:`address_point`, the line feature class :ng911fc:`road_centerline`, and the polygon feature classes :ng911fc:`discrepancyagency_boundary`, :ng911fc:`esb_ems_boundary`, :ng911fc:`esb_fire_boundary`, :ng911fc:`esb_law_boundary`, :ng911fc:`esz_boundary`, and :ng911fc:`psap_boundary`.

The Toolkit does not currently have any functionality related to optional feature classes.

Fields and Domains
------------------

All required feature classes must have the fields specified by the Standard. They must not contain any additional fields (other than those required automatically created for geodatabase feature classes, such as :ng911field:`%OBJECTID`), and the fields must be configured correctly (e.g., the data types must be correct). Further, some fields are required to have domains assigned to them, and those domains must be defined as specified by the Standard.

.. _schema-topology-rules:

Topology Rules
--------------

The Standard prescribes a number of topological relationships that must hold true within and between required feature classes.

One-Member Rules
++++++++++++++++

.. list-table::
   :header-rows: 1

   * - Rule
     - Member
   * - Must Not Overlap (Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - Must Not Have Gaps (Area)
     - :ng911fc:`esb_ems_boundary`
   * - Must Not Have Gaps (Area)
     - :ng911fc:`esb_fire_boundary`
   * - Must Not Have Gaps (Area)
     - :ng911fc:`esb_law_boundary`
   * - Must Not Have Gaps (Area)
     - :ng911fc:`psap_boundary`
   * - Must Not Overlap (Line)
     - :ng911fc:`road_centerline`
   * - Must Not Have Dangles (Line)
     - :ng911fc:`road_centerline`
   * - Must Not Self-Overlap (Line)
     - :ng911fc:`road_centerline`
   * - Must Not Self-Intersect (Line)
     - :ng911fc:`road_centerline`
   * - Must Be Single Part (Line)
     - :ng911fc:`road_centerline`

Two-Member Rules
++++++++++++++++

.. list-table::
   :header-rows: 1

   * - Member 1
     - Rule
     - Member 2
   * - :ng911fc:`address_point`
     - Must Be Properly Inside (Point-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`road_centerline`
     - Must Be Inside (Line-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`esb_ems_boundary`
     - Must Cover Each Other (Area-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`esb_fire_boundary`
     - Must Cover Each Other (Area-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`esb_law_boundary`
     - Must Cover Each Other (Area-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`esz_boundary`
     - Must Cover Each Other (Area-Area)
     - :ng911fc:`discrepancyagency_boundary`
   * - :ng911fc:`psap_boundary`
     - Must Cover Each Other (Area-Area)
     - :ng911fc:`discrepancyagency_boundary`

.. _schema-topology-exceptions:

Exceptions
++++++++++

The :ng911fc:`address_point` and :ng911fc:`road_centerline` feature classes include the field :ng911field:`topoexcept`, which allows users to flag individual features as exempt from certain rules.

``DANGLE_EXCEPTION``
********************

In :ng911fc:`road_centerline` only, setting :ng911field:`topoexcept=DANGLE_EXCEPTION` exempts a feature from the rule *Must Not Have Dangles (Line)*.

``INSIDE_EXCEPTION``
********************

In :ng911fc:`address_point`, setting :ng911field:`topoexcept=INSIDE_EXCEPTION` exempts a feature from the rule *Must Be Properly Inside (Point-Area)* with respect to :ng911fc:`discrepancyagency_boundary`.

In :ng911fc:`road_centerline`, setting :ng911field:`topoexcept=INSIDE_EXCEPTION` exempts a feature from the rule *Must Be Inside (Line-Area)* with respect to :ng911fc:`discrepancyagency_boundary`.

``BOTH_EXCEPTION``
******************

In :ng911fc:`road_centerline` only, setting :ng911field:`topoexcept=BOTH_EXCEPTION` applies the effects of both ``DANGLE_EXCEPTION`` and ``INSIDE_EXCEPTION``
